package com.org.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * @author Rainy-Heights
 * @version 1.0
 * @Date 2023/3/4 20:00
 */
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/**"); //放行static下的所有文件
    }

//    @Override
//    protected void configure(HttpSecurity http) throws Exception {
//        http.csrf().disable()//关闭CSRF权限控制
//                .authorizeRequests()
////                .antMatchers("/static/**", "/auth-login","/register/auth-login","/page/index").permitAll()
//                .antMatchers("*.html").hasRole("ADMIN")
//                .and()
//                .formLogin()//自定义登录
//                .loginPage("/auth-login")//自定义登录界面
//                .loginProcessingUrl("/auth-login")
//                .defaultSuccessUrl("/page/index", true)
//                .failureForwardUrl("/error/pages-404")//登录失败页面
//                .usernameParameter("username")
//                .passwordParameter("password")
//                .and()
//                .rememberMe()
//                .rememberMeParameter("remember")
//                .tokenValiditySeconds(60 * 60 * 24 * 7);//token持续时间,单位为秒
//    }

//    //提供登录
//    @Override
//    //Authentication：身份验证，权限验证
//    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//        auth
//                .userDetailsService(service)
//                .passwordEncoder(new BCryptPasswordEncoder());
//    }
}
